<?php
/**
 * @Author: EYong
 * @Date:   2018-04-27 14:05:59
 * @Last Modified by:   EYong
 * @Last Modified time: 2020-03-26 14:50:24
 */
namespace app\admin\controller;

use app\admin\model\Adminuser as AdminuserModel;
use think\Controller;

class Login extends controller {
	//显示后台登陆页
	public function index() {
		$port   = $_SERVER["SERVER_PORT"];
		$domain = request()->domain();
		// halt($domain);
		// if ($port != '10001' && $domain != 'http://main.gdzhenglian.com') {
		//     $this->redirect('/notFind');
		// }
		return $this->fetch();
	}

	//检测登陆
	public function doLogin() {
		$data['user'] = input('post.user');
		$data['pwd']  = input('post.pwd');
		$captcha      = input('post.captcha');
		$captchaid    = input('post.captchaid');

		//检测验证码是否正确
		// if (!captcha_check($captcha, $captchaid)) {
		//     $result = ['errorCode' => 1, 'msg' => '验证码错误' . $captcha];
		// } else {
		//检测帐号密码
		$userModel = new AdminuserModel();
		$result    = $userModel->checkUser($data);
		// }
		if ($result['errorCode'] == 0) {
			session('module_mms', 0);
		}
		return json($result);
	}

	public function loginOut() {
		session(null);
		$this->redirect('Login/index');
	}

}
